<?php

// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;

use OT\DataDictionary;

/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class ListController extends HomeController {


   
   public function _initialize() {
       $menu=D('Category')->getMenu();
        $this->assign("menu",$menu);
         $logo = D('Document')->lists(80); //logo         
         $logos=D('Document')->detail($logo[0]['id']);
         $this->assign('logo',$logos);
         
         //網站設置
         $config=D('Document')->lists(81);
         $configs=D('Document')->detail($config[0]['id']);
         $this->assign('config',$configs);
         
   }

      //明星更多
    public function index(){
        
        //藝人管理介紹
        //藝人管理簡介
        $artistintro = D('Document')->lists(65);
        $artistintros = D('Document')->detail($artistintro[0]['id']);
        $this->assign('artistintro', $artistintros);
        
       //明星列表
        $cate=$_GET['cate'];
        // 艺人管理    
        $rImages = D('Document')->lists($cate);
        foreach ($rImages as $key => $value) {
            $rImage[] = D('Document')->detail($value['id']);
        }
        $this->assign('list', $rImage);
       
        $this->display('list');
    }
    
    //明星詳細頁
    public function artist_info(){
        $id=$_GET['id'];
        $detail=D('Document')->detail($id);
       
        if(strpos($detail['photo'], ',')){
                    $detail['photo'] = explode(',', $detail['photo']);                    
                }
         if(strpos($detail['images'], ',')){
                    $detail['images'] = explode(',', $detail['images']);                    
                }
       
        $this->assign('artist', $detail);
        $this->display();
        
    }
    
   
    
    
    //活動策劃的更多
    public function list_activity(){
        //分類
        $types=D('Document')->lists(86);
        $this->assign('types',$types);
        if(IS_POST){
            $types=$_POST['types'];
            $this->assign('Ntypes', $types);
            $id=$_GET['cate'];
            $list=D('Document')->event($id,$types);
            
            $this->assign('lists',$list);
            
        }else{
            //圖片
            $id=$_GET['cate'];
            $list=D('Document')->event($id,$types[0]['id']);
            $this->assign('lists',$list);      
         }
            $this->display();
    }
    
    //除藝人管理和活動策劃其他的更多
    public function list2(){
        $id=$_GET['cate'];
        $this->assign('cate',$id);
        $list=D('Document')->pages2($id);
        $this->assign('lists',$list);
       
        $info=D('Category')->info($id);
        if($info['pid']!=0){
            $cates=D('Category')->info($info['pid']);
            $this->assign('title',$cates['title']);
        }else{
            $this->assign('title',$info['title']);
        }
        $this->display();
    }
    
    //詳細頁
    public function page_info(){
        $id=$_GET['id'];
        
        $detail=D('Document')->detail($id);
        if(strpos($detail['photo'], ',')){
                    $detail['photo'] = explode(',', $detail['photo']);                    
                }
      
        $this->assign('cate',$detail['category_id']);
        $this->assign('detail', $detail);
        $this->display();
    }
}
